package com.ruoyi.gis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gis.domain.DatasetFunctionParam;
import com.ruoyi.gis.service.IDatasetFunctionParamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据集算法参数Controller
 *
 * @author rww
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/earthai/funcParam")
public class DatasetFunctionParamController extends BaseController
{
    @Autowired
    private IDatasetFunctionParamService datasetFunctionParamService;

    /**
     * 查询数据集算法参数列表
     */
//    @PreAuthorize("@ss.hasPermi('earthai:funcParam:list')")
    @GetMapping("/list")
    public TableDataInfo list(DatasetFunctionParam datasetFunctionParam)
    {
        startPage();
        List<DatasetFunctionParam> list = datasetFunctionParamService.selectDatasetFunctionParamList(datasetFunctionParam);
        return getDataTable(list);
    }

    /**
     * 导出数据集算法参数列表
     */
//    @PreAuthorize("@ss.hasPermi('earthai:funcParam:export')")
    @Log(title = "数据集算法参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DatasetFunctionParam datasetFunctionParam)
    {
        List<DatasetFunctionParam> list = datasetFunctionParamService.selectDatasetFunctionParamList(datasetFunctionParam);
        ExcelUtil<DatasetFunctionParam> util = new ExcelUtil<DatasetFunctionParam>(DatasetFunctionParam.class);
        util.exportExcel(response, list, "数据集算法参数数据");
    }

    /**
     * 获取数据集算法参数详细信息
     */
//    @PreAuthorize("@ss.hasPermi('earthai:funcParam:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(datasetFunctionParamService.selectDatasetFunctionParamById(id));
    }

    /**
     * 新增数据集算法参数
     */
//    @PreAuthorize("@ss.hasPermi('earthai:funcParam:add')")
    @Log(title = "数据集算法参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DatasetFunctionParam datasetFunctionParam)
    {
        return toAjax(datasetFunctionParamService.insertDatasetFunctionParam(datasetFunctionParam));
    }

    /**
     * 修改数据集算法参数
     */
//    @PreAuthorize("@ss.hasPermi('earthai:funcParam:edit')")
    @Log(title = "数据集算法参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DatasetFunctionParam datasetFunctionParam)
    {
        return toAjax(datasetFunctionParamService.updateDatasetFunctionParam(datasetFunctionParam));
    }

    /**
     * 删除数据集算法参数
     */
//    @PreAuthorize("@ss.hasPermi('earthai:funcParam:remove')")
    @Log(title = "数据集算法参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(datasetFunctionParamService.deleteDatasetFunctionParamByIds(ids));
    }
}
